#include <cstdio>

int main(int argc, char const *argv[]) {
    long long a, b;
    int system;
    while (scanf("%d", &system) != EOF) {
        if (system == 0)
            break;
        scanf("%lld%lld", &a, &b);
        long long sum = a + b;
        int result[50], size = 0;
        do { //in case of result is 0
            result[size++] = sum % system;
            sum /= system;
        } while (sum != 0);
        for (int i = size - 1; i >= 0; i--)
            printf("%d", result[i]);
        printf("\n");
    }
    return 0;
}